package com.example.demo.quartz;

import com.example.demo.repo.SysUserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 *必须同时有@Configuration & @EnableScheduling
 */
@EnableScheduling
@Configuration
public class MyScheduledTasks {

    @Autowired
    private SysUserRepository sysUserRepository;
    @Scheduled(cron ="0/5 * * * * ? " )
    public void sayHello(){

        System.out.println("ni hao wa   nimabi "+sysUserRepository.findByUsername("root").getPassword());
    }

    @Scheduled(cron ="0/3 * * * * ? " )
    public void sayHello2(){

        System.out.println("ni hao wa   nimabi "+sysUserRepository.findByPassword("12").getUsername());
    }
}
